const cloud = require('wx-server-sdk');
const utils = require('../utils/index');  
cloud.init({
  env: cloud.DYNAMIC_CURRENT_ENV
});
const db = cloud.database();

exports.main = async (event, context) => {

  //1. 获取姓名数据
  let _openid = event.params._openid;
  let passCountArray = [1,0,0,0,0,0]
  let passTimeArray = [0,0,0,0,0,0]

  // 2. 调用数据库进行存储
  try {
    return await db.collection(utils.collectionName).add({
      data:{
        _openid,
        passCountArray,
        passTimeArray
      }
    })
  } catch (error) {
    console.log(error);
    return null;
  }
};